{% extends 'frontend/common/basic_list.html' %}

{% block list_title %}
    主机
{% endblock %}

{% block list_filter %}
    <div class="col-sm-3">
        <div class="input-group">
            <input type="text" name="host__contains" placeholder="主机名"
                   value="{{ kwargs.host__contains }}"
                   class="input-sm form-control">

        </div>
    </div>
    <div class="col-sm-5">
        <div class="input-group">
            <button type="submit" class="btn btn-sm btn-primary"><i class="fa fa-search"></i> 搜索</button>
            &nbsp;
            <a href="host_add/"
               class="btn btn-sm btn-success"> 新增</a>&nbsp;
            <a href="javascript:void(0)"
               onclick="scan_host()"
               class="btn btn-sm btn-success"> 扫描主机</a>
            &nbsp;
            <a href="javascript:void(0)"
               onclick="deleteBatch()"
               class="btn btn-sm btn-danger"><i class="fa fa-trash"></i> 批量删除</a>
        </div>
    </div>
    <script>
        function scan_host() {
            $('#loading_div').show()
            $('#tb').hide()
            $.get('/frontend/cmdb/host_list/scan_host_job/', function () {
                location.reload()
            })
        }
    </script>
{% endblock %}

{% block list_content %}
    <div class="ibox " style="display: none;" id="loading_div">
        <div class="spiner-example">
            <div class="sk-spinner sk-spinner-three-bounce">
                <div class="sk-bounce1"></div>
                <div class="sk-bounce2"></div>
                <div class="sk-bounce3"></div>
            </div>
        </div>
    </div>
    <table id="tb" class="table table-striped table-bordered table-hover dataTables-example dataTable">
        <thead>
        <tr>
            <th style="width:3%;"><input id="checkall" type="checkbox" class="i-checks"></th>
            <th style="width: 8%;">主机组</th>
            <th style="width: 8%;">主机DNS名称</th>
            <th style="width: 8%;">主机名</th>
            <th style="width: 8%;">机房</th>
            <th style="width: 8%;">系统内核</th>
            <th style="width: 8%;">操作系统</th>
            <th style="width: 8%;">使用SaltSSH</th>
            <th style="width: 8%;">Minion状态</th>
            <th style="width: 8%;">创建时间</th>
            <th style="width: 8%;">更新时间</th>
            <th style="width:15%;">操作</th>
        </tr>
        </thead>
        <tbody>
        {% for o in result_list %}
            <tr>
                <td>
                    <input type="checkbox" class="i-checks icheck" id="{{ o.id }}" name="input[]">
                </td>
                <td>{% ifequal o.host_group None %}
                    无
                {% else %}
                    {{ o.host_group }}
                {% endifequal %}
                </td>
                <td>{{ o.host_name }}</td>
                <td>{{ o.host }}</td>
                <td>{% ifequal o.idc None %}
                    无
                {% else %}
                    {{ o.idc }}
                {% endifequal %}</td>
                <td>{{ o.kernel }}</td>
                <td>{{ o.os }}</td>
                <td>{{ o.enable_ssh|enablessh_status_filter }}</td>
                <td>{{ o.minion_status|minion_status_filter }}</td>
                <td>{{ o.create_time }}</td>
                <td>{{ o.update_time }}</td>
                <td>
                    <a href="/frontend/cmdb/host_list/{{ o.id }}/host_edit/"
                       class="btn  btn-sm btn-info">编辑</a>
                    <a href="/frontend/cmdb/host_list/{{ o.id }}/delete_entity/"
                       class="btn  btn-sm btn-danger">删除</a>
                </td>
            </tr>
        {% endfor %}
        </tbody>
    </table>
{% endblock %}